﻿<phone:PhoneApplicationPage 
    x:Class="PhoneInfo.Page.DownloadManager"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
    shell:SystemTray.IsVisible="false" Style="{StaticResource TransitionPageStyle}"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:delay="clr-namespace:Delay;assembly=PhonePerformance"
    xmlns:local="clr-namespace:PhoneInfo"
    >
    <phone:PhoneApplicationPage.Resources>
        <local:FixEmptyUrl x:Key="FixUrl"/>
        <local:IntToString x:Key="IntToStr"/>
        <local:TypeToVis  x:Key="TypeToVis"/>
        <local:StringToString  x:Key="StringToString"/>
        <ControlTemplate x:Key="PhoneProgressBar SliderThumb" TargetType="Thumb">
        	<Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4"/>
        </ControlTemplate>
        <Style x:Key="PhoneProgressBar SliderStyle" TargetType="Slider">
        	<Setter Property="Maximum" Value="3000"/>
        	<Setter Property="Minimum" Value="0"/>
        	<Setter Property="Value" Value="0"/>
        	<Setter Property="Opacity" Value="0"/>
        	<Setter Property="IsTabStop" Value="False"/>
        	<Setter Property="Template">
        		<Setter.Value>
        			<ControlTemplate TargetType="Slider">
        				<Grid IsHitTestVisible="False">
        					<Grid x:Name="HorizontalTemplate">
        						<Grid.ColumnDefinitions>
        							<ColumnDefinition Width="Auto"/>
        							<ColumnDefinition Width="Auto"/>
        							<ColumnDefinition Width="*"/>
        						</Grid.ColumnDefinitions>
        						<RepeatButton x:Name="HorizontalTrackLargeChangeDecreaseRepeatButton" Grid.Column="0" Height="0" Template="{x:Null}"/>
        						<Thumb x:Name="HorizontalThumb" Grid.Column="1" Foreground="{TemplateBinding Foreground}" Height="4" IsTabStop="False" Template="{StaticResource PhoneProgressBar SliderThumb}"/>
        						<RepeatButton x:Name="HorizontalTrackLargeChangeIncreaseRepeatButton" Grid.Column="2" Height="0" Template="{x:Null}"/>
        					</Grid>
        				</Grid>
        			</ControlTemplate>
        		</Setter.Value>
        	</Setter>
        </Style>
        <Style x:Key="ProgressBar Style1" TargetType="ProgressBar ">
        	<Setter Property="Foreground" Value="{StaticResource PhoneAccentBrush}"/>
        	<Setter Property="Background" Value="{StaticResource PhoneAccentBrush}"/>
        	<Setter Property="Maximum" Value="100"/>
        	<Setter Property="IsHitTestVisible" Value="False"/>
        	<Setter Property="Padding" Value="{StaticResource PhoneHorizontalMargin}"/>
        	<Setter Property="Template">
        		<Setter.Value>
        			<ControlTemplate TargetType="ProgressBar ">
        				<Grid>
        					<VisualStateManager.VisualStateGroups>
        						<VisualStateGroup x:Name="CommonStates">
        							<VisualState x:Name="Determinate"/>
        							<VisualState x:Name="Indeterminate">
        								<Storyboard Duration="00:00:04.4" RepeatBehavior="Forever">
        									<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="IndeterminateRoot">
        										<DiscreteObjectKeyFrame KeyTime="0">
        											<DiscreteObjectKeyFrame.Value>
        												<Visibility>Visible</Visibility>
        											</DiscreteObjectKeyFrame.Value>
        										</DiscreteObjectKeyFrame>
        									</ObjectAnimationUsingKeyFrames>
        									<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DeterminateRoot">
        										<DiscreteObjectKeyFrame KeyTime="0">
        											<DiscreteObjectKeyFrame.Value>
        												<Visibility>Collapsed</Visibility>
        											</DiscreteObjectKeyFrame.Value>
        										</DiscreteObjectKeyFrame>
        									</ObjectAnimationUsingKeyFrames>
        									<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Value" Storyboard.TargetName="Slider1">
        										<EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="1000">
        											<EasingDoubleKeyFrame.EasingFunction>
        												<ExponentialEase EasingMode="EaseOut" Exponent="1"/>
        											</EasingDoubleKeyFrame.EasingFunction>
        										</EasingDoubleKeyFrame>
        										<LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="2000"/>
        										<EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="3000">
        											<EasingDoubleKeyFrame.EasingFunction>
        												<ExponentialEase EasingMode="EaseIn" Exponent="1"/>
        											</EasingDoubleKeyFrame.EasingFunction>
        										</EasingDoubleKeyFrame>
        									</DoubleAnimationUsingKeyFrames>
        									<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2" Storyboard.TargetProperty="Value" Storyboard.TargetName="Slider2">
        										<EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="1000">
        											<EasingDoubleKeyFrame.EasingFunction>
        												<ExponentialEase EasingMode="EaseOut" Exponent="1"/>
        											</EasingDoubleKeyFrame.EasingFunction>
        										</EasingDoubleKeyFrame>
        										<LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="2000"/>
        										<EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="3000">
        											<EasingDoubleKeyFrame.EasingFunction>
        												<ExponentialEase EasingMode="EaseIn" Exponent="1"/>
        											</EasingDoubleKeyFrame.EasingFunction>
        										</EasingDoubleKeyFrame>
        									</DoubleAnimationUsingKeyFrames>
        									<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4" Storyboard.TargetProperty="Value" Storyboard.TargetName="Slider3">
        										<EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="1000">
        											<EasingDoubleKeyFrame.EasingFunction>
        												<ExponentialEase EasingMode="EaseOut" Exponent="1"/>
        											</EasingDoubleKeyFrame.EasingFunction>
        										</EasingDoubleKeyFrame>
        										<LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="2000"/>
        										<EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="3000">
        											<EasingDoubleKeyFrame.EasingFunction>
        												<ExponentialEase EasingMode="EaseIn" Exponent="1"/>
        											</EasingDoubleKeyFrame.EasingFunction>
        										</EasingDoubleKeyFrame>
        									</DoubleAnimationUsingKeyFrames>
        									<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.6" Storyboard.TargetProperty="Value" Storyboard.TargetName="Slider4">
        										<EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="1000">
        											<EasingDoubleKeyFrame.EasingFunction>
        												<ExponentialEase EasingMode="EaseOut" Exponent="1"/>
        											</EasingDoubleKeyFrame.EasingFunction>
        										</EasingDoubleKeyFrame>
        										<LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="2000"/>
        										<EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="3000">
        											<EasingDoubleKeyFrame.EasingFunction>
        												<ExponentialEase EasingMode="EaseIn" Exponent="1"/>
        											</EasingDoubleKeyFrame.EasingFunction>
        										</EasingDoubleKeyFrame>
        									</DoubleAnimationUsingKeyFrames>
        									<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.8" Storyboard.TargetProperty="Value" Storyboard.TargetName="Slider5">
        										<EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="1000">
        											<EasingDoubleKeyFrame.EasingFunction>
        												<ExponentialEase EasingMode="EaseOut" Exponent="1"/>
        											</EasingDoubleKeyFrame.EasingFunction>
        										</EasingDoubleKeyFrame>
        										<LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="2000"/>
        										<EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="3000">
        											<EasingDoubleKeyFrame.EasingFunction>
        												<ExponentialEase EasingMode="EaseIn" Exponent="1"/>
        											</EasingDoubleKeyFrame.EasingFunction>
        										</EasingDoubleKeyFrame>
        									</DoubleAnimationUsingKeyFrames>
        									<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Slider1">
        										<DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
        										<DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
        									</DoubleAnimationUsingKeyFrames>
        									<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Slider2">
        										<DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
        										<DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
        									</DoubleAnimationUsingKeyFrames>
        									<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Slider3">
        										<DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
        										<DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
        									</DoubleAnimationUsingKeyFrames>
        									<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.6" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Slider4">
        										<DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
        										<DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
        									</DoubleAnimationUsingKeyFrames>
        									<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.8" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Slider5">
        										<DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
        										<DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
        									</DoubleAnimationUsingKeyFrames>
        								</Storyboard>
        							</VisualState>
        						</VisualStateGroup>
        					</VisualStateManager.VisualStateGroups>
        					<Grid x:Name="DeterminateRoot" Margin="{TemplateBinding Padding}" Visibility="Visible">
        						<Rectangle x:Name="ProgressBar Track" Fill="{TemplateBinding Background}" Height="10"/>
        						<Rectangle x:Name="ProgressBar Indicator" Fill="{TemplateBinding Foreground}" HorizontalAlignment="Left" Height="10"/>
        					</Grid>
        					<Border x:Name="IndeterminateRoot" Margin="{TemplateBinding Padding}" Visibility="Collapsed">
        						<Grid>
        							<Slider x:Name="Slider1" Foreground="{TemplateBinding Foreground}" Style="{StaticResource PhoneProgressBar SliderStyle}"/>
        							<Slider x:Name="Slider2" Foreground="{TemplateBinding Foreground}" Style="{StaticResource PhoneProgressBar SliderStyle}"/>
        							<Slider x:Name="Slider3" Foreground="{TemplateBinding Foreground}" Style="{StaticResource PhoneProgressBar SliderStyle}"/>
        							<Slider x:Name="Slider4" Foreground="{TemplateBinding Foreground}" Style="{StaticResource PhoneProgressBar SliderStyle}"/>
        							<Slider x:Name="Slider5" Foreground="{TemplateBinding Foreground}" Style="{StaticResource PhoneProgressBar SliderStyle}"/>
        						</Grid>
        					</Border>
        				</Grid>
        			</ControlTemplate>
        		</Setter.Value>
        	</Setter>
        </Style>
    </phone:PhoneApplicationPage.Resources>
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="{Binding Source={StaticResource Theme}, Path=cuTheme.TextBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
            <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
                <StackPanel>
                    <ProgressBar  Foreground="Orange" x:Name="ProgBar" Visibility="Visible"  IsIndeterminate="True" Height="10" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0" Grid.ColumnSpan="2"  Width="480" />
                </StackPanel>
                <TextBlock Text="下载管理" Margin="9,-7,0,0" Foreground="{Binding Source={StaticResource Theme}, Path=cuTheme.TitleBrush}"  FontSize="50"/>
            </StackPanel>
            <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <ListBox x:Name="listbox" ItemsSource="{Binding}" Margin="12,0,0,0">
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                    </Style>
                </ListBox.ItemContainerStyle>
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <toolkit:ExpanderView Margin="0,0,0,8" 
                                              Header="{Binding}"                                             
                                              Expander="{Binding}"
                                              ItemsSource="{Binding Item}"
                                              IsExpanded="{Binding IsExpanded, Mode=TwoWay}"
                                              >
                            <toolkit:ExpanderView.HeaderTemplate>
                                <DataTemplate>
                                    <TextBlock     Text="{Binding ContentInfo}"
                                                   Foreground="{Binding Source={StaticResource Theme}, Path=cuTheme.SecondTextBrush}"
                                                   FontSize="{StaticResource PhoneFontSizeExtraLarge}" 
                                                   />
                                </DataTemplate>
                            </toolkit:ExpanderView.HeaderTemplate>
                                <toolkit:ExpanderView.ExpanderTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding ExpanderInfo}"    
									    Foreground="{Binding Source={StaticResource Theme}, Path=cuTheme.SecondTextBrush}"/>
                                    </DataTemplate>
                                </toolkit:ExpanderView.ExpanderTemplate>
                                <toolkit:ExpanderView.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal" Margin="5" Tap="StackPanel_Tap">
                                            <toolkit:ContextMenuService.ContextMenu>
                                                <toolkit:ContextMenu>
                                                    <toolkit:MenuItem Header="删除"  Click="Cancel"/>
                                                </toolkit:ContextMenu>
                                            </toolkit:ContextMenuService.ContextMenu>
                                            <Image  delay:LowProfileImageLoader.UriSource="{Binding Icon, Converter={StaticResource FixUrl}}" Width="70" Height="70" />
                                            <StackPanel>
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Margin="5,0,0,0" Text="文件大小：" FontSize="16" Foreground="#7c7c7c"/>
                                                    <TextBlock Margin="5,0,0,0" Text="{Binding Filesize}" FontSize="16"  Foreground="#7c7c7c"/>
                                                    <TextBlock Margin="5,0,0,0" Text="下载次数：" FontSize="16"  Foreground="#7c7c7c"/>
                                                    <TextBlock Margin="5,0,0,0" Text="{Binding Downcount}" FontSize="16"  Foreground="#7c7c7c"/>                                             
                                                </StackPanel>
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Margin="5,0,0,0" Text="评分：" FontSize="16"  Foreground="#7c7c7c"/>
                                                    <TextBlock Margin="5,0,0,0" Text="{Binding Score}" FontSize="16"  Foreground="#7c7c7c"/>
                                                    <TextBlock Margin="5,0,0,0" Text="分" FontSize="16"  Foreground="#7c7c7c"/>
                                                </StackPanel>
                                                <StackPanel  Orientation="Horizontal">
                                                    <TextBlock Margin="5,0,0,0" Text="添加时间"  Foreground="#7c7c7c" FontSize="16"/>
                                                    <TextBlock Margin="5,0,0,0" Text="{Binding Addtime}" FontSize="16"  Foreground="#7c7c7c"/>
                                                </StackPanel>
                                                <StackPanel  Orientation="Horizontal" Visibility="{Binding Type, Converter={StaticResource TypeToVis}}">
                                                    <TextBlock Margin="5,0,0,0" Text="下载进度:" FontSize="16"  Foreground="#7c7c7c"/>
                                                    <ProgressBar  Margin="5,0,0,0" Minimum="0" Maximum="{Binding TotalSize, Converter={StaticResource IntToStr}}" Value="{Binding HasFilesize}" Width="250" Height="30" Style="{StaticResource ProgressBar Style1}" Background="Gainsboro" Foreground="#FF65C6E3"/>
                                                </StackPanel>
                                                <StackPanel  Orientation="Horizontal">
                                                    <TextBlock Margin="5,0,0,0" Text="{Binding Type, Converter={StaticResource StringToString}}" FontSize="16"  Foreground="#7c7c7c"/>
                                                </StackPanel>
                                            </StackPanel>
                                        </StackPanel>                                         
                                    </DataTemplate>
                                </toolkit:ExpanderView.ItemTemplate>
                            </toolkit:ExpanderView>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>
    </Grid>
  
</phone:PhoneApplicationPage>
